package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;

@Mapper
public interface UserMapper {

    @Select("select * from user where openid = #{openid}")
    User findkUser(String openid);

    long insertUser(User user);

    @Select("select * from user where id = #{userId}")
    User getById(Long userId);

    /**
     * 查询某一天的新增用户
     * @param begin
     * @param end
     * @return
     */
    @Select("select count(*) from user where create_time<#{end} and create_time>#{begin}")
    Integer selectByTime(LocalDateTime begin, LocalDateTime end);

    /**
     * 查询总用户数（到某天为止）
     * @param end
     */
    @Select("select count(*) from user where create_time<#{end}")
    Integer selectBeforeOnDay(LocalDateTime end);
}
